#ifndef CLIB_COMMAND_H
#define CLIB_COMMAND_H

#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#define CLIB_CONF_MAX_TOKEN     256
#define CLIB_CONF_MAX_NAME      256
#define CLIB_CONF_MAX_LEN       512

#include "clib_type.h"
#include "clib_config.h"


typedef struct clib_conf_s      clib_conf_t;
typedef struct clib_command_s   clib_command_t;

struct clib_conf_s {
    i32_t                      deal;
    i32_t                      argc;
    i08_t                     *argv[CLIB_CONF_MAX_TOKEN];
    void                      *conf;
};

struct clib_command_s {
    /** 字段名称 **/
    const i08_t               *name;
    /** 字段描述 **/
    const i08_t               *desc;
    /** 字段类型 **/
    i32_t                      type;
    /** 字段偏移量 **/
    u16_t                      offset;
    /** 字段内存大小 **/
    u16_t                      size;
    /** 字段配置函数  **/
    i32_t                     (*slot)(clib_conf_t *args, clib_command_t *cmd, void *conf);
};

i32_t
clib_pars_config(clib_config_t *conf, clib_conf_t *args);

i32_t
clib_pars_cmd_line(u08_t *line, clib_conf_t *args);

i32_t
clib_set_i08_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_u08_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_i16_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_u16_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_i32_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_u32_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_i64_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_u64_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

i32_t
clib_set_str_type(clib_conf_t *args, clib_command_t *cmd, void *conf);

#ifdef __cplusplus
}
#endif

#endif